<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <th:block th:include="common.html :: source"></th:block>
    <link href="/static/layui/css/layui.css" rel="stylesheet">
</head>
<style>
    body{
        margin: 20px;
    }
    #kuang{
        margin-top: 20px;
        margin-left: 10%;
        border: 2px #cccccc solid;
        width: 900px;
        height: 500px;
        background-color: rgba(255,255,255,0.5);
    }
</style>

<body>
<div style="" class="panel-head layui-anim layui-anim-down"><strong> 修改信息</strong></div>
<div id="kuang">
<div class="layui-input-block layui-form" id="modifyClass"
     lay-filter="updateClass" style="margin-top: 30px">
    <form class="layui-form" action="" lay-filter="example">
        <!--    ID隐藏-->
        <input type="hidden" class="layui-input" name="categoryId" id="categoryId" readonly/>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">商户名称</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" th:value="${session.categoryInfo.getCategoryName()}" name="categoryName" id="categoryName" lay-verify="required"/>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">标签</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" th:value="${session.categoryInfo.getCategoryType()}" name="categoryType" id="categoryType" lay-verify="required" disabled/>
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">介绍</label>
            <div class="layui-input-inline">
                <textarea th:text="${session.categoryInfo.getIntroduce()}" style="width: 380px;height: 150px;padding: 5px" type="text" class="layui-input"  name="introduce" id="introduce" lay-verify="required">
                </textarea>

            </div>
        </div>


        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="enmodify">确认修改</button>
            </div>
        </div>
    </form>
</div>
</div>

<script src="/layui/layui.js" charset="UTF-8"></script>
<script type="text/javascript">
    layui.use(['layer', 'form'], function () {
        var layer = layui.layer;
        var form = layui.form;
        form.on('submit()', function () {
            $.post({
                url: '/merchant/updateInfo',
                data: {
                    "categoryId": $("#categoryId").val(),
                    "categoryName": $("#categoryName").val(),
                    "categoryType": $("#categoryType").val(),
                    "introduce": $("#introduce").val(),
                },
                success: function (data) {
                    if (data === "true") {
                        layer.msg('修改成功！', {icon: 6, offset: "auto", time: 2000});//提示框
                    } else {
                        layer.msg('修改失败！', {icon: 5, offset: "auto", time: 2000});//提示框
                    }
                    setTimeout(function () {
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);//关闭弹出层
                        parent.location.reload();//重新加载父页面表格
                    }, 2100);
                }
            });
            return false;
        });
    });
</script>
</body>
</html>

